home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 September / CHIP Eylül 1998.iso / Slackwar / docs / slack-docs / base / start.dip < prev    next >
Text File  |  1996-05-09  |  3KB  |  107 lines

  1. #!/bin/sh
  2. # start.dip: the main control script for talking SLIP or PPP to DIS.
  3. # Copyright 1994-6 John A. Phillips - john@linux.demon.co.uk
  4. # usage: start.dip [slip|ppp]
  5.  
  6. # Initialization.
  7. # ===============
  8.  
  9. # Assign the protocol if specified, or use the default.
  10. protocol=${1:-slip}
  11.  
  12. # Check for a valid protocol.
  13. if [ $protocol != "ppp" -a $protocol != "slip" ]; then
  14.     echo "usage: start.dip [ppp|slip]"
  15.     exit 1
  16. fi
  17.  
  18. # If the script is interrupted, kill dip and exit.
  19. trap '/sbin/dip -k 2>/dev/null; echo ""; exit 1' \
  20.     SIGHUP SIGINT SIGQUIT SIGTERM
  21.  
  22. # Start up the main dialup IP connection.
  23. # =======================================
  24.  
  25. # Use this section for SLIP.
  26. # --------------------------
  27. if [ $protocol = "slip" ]; then
  28.     /sbin/dip /usr/local/etc/demon_slip
  29.  
  30. # Did dip succeed?
  31.     dip_result=$?
  32.     if [ $dip_result -ne 0 ]; then
  33.         echo dip failed with exit code $dip_result
  34.         exit 1
  35.     fi
  36.  
  37. # SLIP sometimes seems to need time to settle.
  38.     sleep 5
  39.  
  40. # Connected.
  41.     echo "SLIP connected."
  42. fi
  43.  
  44. # Use this section for PPP.
  45. # -------------------------
  46. if [ $protocol = "ppp" ]; then
  47.     /sbin/dip /usr/local/etc/demon_ppp
  48.  
  49. # Did dip succeed?
  50.     dip_result=$?
  51.     if [ $dip_result -ne 0 ]; then
  52.         echo dip failed with exit code $dip_result
  53.         exit 1
  54.     fi
  55.  
  56. # Wait for the signal that IP has come up via PPP.
  57.     echo "Waiting for PPP to come up ..."
  58.     wait_time=21
  59.     trap "break" SIGCONT
  60.     while [ $wait_time -gt 0 ]; do
  61.         sleep 1
  62.         wait_time=`expr $wait_time - 1`
  63.         echo -n -e "\\r$wait_time "
  64.     done
  65.     trap SIGCONT
  66.     echo ""
  67.  
  68. # Did a signal arrive, or was there a time out?
  69.     if [ $wait_time -le 0 ]; then
  70.         echo "PPP timed out."
  71.         /bin/killall pppd 2>/dev/null
  72.         /sbin/dip -k 2>/dev/null
  73.         exit 2
  74.     fi
  75.  
  76. # Connected.
  77.     echo "PPP connected."
  78. fi
  79.  
  80. # Start up IP applications.
  81. # =========================
  82.  
  83. # Check to see whether we have any waiting mail.
  84. /usr/local/sbin/querypost &
  85.  
  86. # Set the system and CMOS date and time from the network.
  87. /usr/local/sbin/setclock &
  88.  
  89. # Run the mail queue.
  90. /usr/sbin/sendmail -q &
  91.  
  92. # Now process incoming and outgoing news.
  93. # /usr/local/sbin/procnews &
  94.  
  95. # Print out Demon status information.
  96. /usr/local/sbin/querystatus &
  97.  
  98. # Start up any auto-logout procedures (if you have them).
  99. # =======================================================
  100.  
  101. # if [ $protocol = "slip" ]; then
  102. #     /usr/local/sbin/slip_idle
  103. # fi
  104. # if [ $protocol = "ppp" ]; then
  105. #     /usr/local/sbin/pppd_idle
  106. # fi
  107.